package icms.ORM;

import org.hibernate.Session;
import org.hibernate.cfg.Configuration;

public class MySessionFactroy {
	private static String CONFIG_FILE_LOCATION="/hibernate.cfg.xml";
	private static Configuration configuration=new Configuration();
	private static org.hibernate.SessionFactory sessionFactory;
	static{
		try{
			configuration.configure(CONFIG_FILE_LOCATION);
			sessionFactory=configuration.buildSessionFactory();
		}catch(Exception e){
			System.err.println("creating sessionFactory error!");
			e.printStackTrace();
		}
	}
	public MySessionFactroy(){
		
	}
	public static org.hibernate.SessionFactory getSessionFactory(){
		return sessionFactory;
	}
	public static Session getSession(){
		return sessionFactory.openSession();
	}
}
